﻿using System.Web.Http;
using LsTool;
using LsTool.ApiModels;
using Newtonsoft.Json;
using Zapi.Api;

namespace Zapi.Controllers
{
    public class TController : ZapiController
    {


        public TController()
        {

        }
        /// <summary>
        /// get测试
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpGet]
        public BaseOut T1([FromUri]TestIn model)
        {
            // throw ToError("自定义错误");

           // var i = 1 / model.N;
            return new TestOut()
            {
                Txt = model.X1,
                Txt2 =  model.X2
            };
        }

        /// <summary>
        /// post测试
        /// </summary>
        /// <param name="model"></param>
        /// <exception cref="MyError"></exception>
        /// <returns></returns>
        [HttpPost]
        public BaseOut T2(TestIn model)
        {
            return new TestOut()
            {
                Txt = model.X1,
                Txt2 = model.X2,
                Head = null,
                Time = model.Time.ToHHmm(),
                JsonList = JsonConvert.SerializeObject(model.Listint)
            };
        }

        /// <summary>
        /// get测试 头部
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public BaseOut T3()
        {
            return ToOk(Token);
        }
        /// <summary>
        /// post测试头部
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public BaseOut T4()
        {
            return ToOk(Token);
        }

    }
}
